package com.yh.dao;

import com.yh.javabean.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Auther: als
 * @Date: 2024/5/24 - 05 - 24 - 16:43
 * @Description: com.yh.dao
 * @version: 1.0
 */
public interface RoleDao {
    //根据用户查角色信息

    Role selectByUid(int uid);

    @Select("select * from role where id=#{id}")
    Role selectById(int id);

    //查询所有角色
    @Select("select * from role")
    List<Role> selectAll();
     @Insert("insert into role (roleName,roleDesc) values(#{roleName},#{roleDesc})")
    int insertRole(Role role);

     @Update("update role set roleName=#{roleName},roleDesc=#{roleDesc} where id=#{id}")
     int updateRole(Role role);

     //删除角色
    @Delete("delete from role where id=#{id}")
    int deleteById(int id);
    //批量删除角色
    @Delete("<script>" +
            "        delete from role where id in \n" +
            "        <foreach collection=\"ids\" item=\"id\" open=\"(\" close=\")\" separator=\",\">\n" +
            "            #{id}\n" +
            "        </foreach>" +
            "</script>")
    int deleteByList(@Param("ids") List<Integer> ids);

}